<?php


namespace app\api\validate;


use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'user_name' => 'max:20|requireIf:account_type,2',
        'school_name' => 'max:50|requireIf:account_type,2',
        'mobile' => 'mobile|require',//|unique:user'
        'password' => 'require',
        'account_type' => 'integer|require',
        'token' => 'requireIf:account_type,1'
    ];
    protected  $message = [
        'user_name.require' => '姓名不能为空',
        'user_name.max' => '姓名最多20个字符',
        'school_name.require' => '学校不能为空',
        'school_name.max' => '学校名称最多50字',
        'school_address.require' => '学校地址最多50字',
        'school_address.max' => '学校地址最多50字',
        'mobile.mobile' => '电话号码格式错误',
        'mobile.require' => '手机号不能为空',
        'mobile.unique' => '电话号不能重复',
        'password.require' => '密码不能为空',
        'account_type.integer' => '账户 类型必须是整数',
        'account_type.require' => '账户类型不能为空',
        'token.require' => '验证码不能为空'
    ];
    protected $scene = [
        'register' => ['user_name','school_name','school_address','mobile','password','account_type'],
        'login' =>['mobile','password']
    ];
}